package com.example.petstore_2.controller;

import com.example.petstore_2.common.CommonResponse;
import com.example.petstore_2.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * 获取某个category
     * @param category
     * @return
     */
    @GetMapping("/categorys/{category}")
    public CommonResponse categoryForm(@PathVariable("category") String category){
//        System.out.println(category);
        return categoryService.getCategoryByCategoryId(category);
    }

    /**
     * 获取全部category
     * @return
     */
    @GetMapping("/categorys")
    public CommonResponse getAllCategory(){
        return categoryService.getCategoryList();
    }

}
